//
//  WMEFindCollectionHeadView.m
//  everyDay_duiTang
//
//  Created by 恩叔 on 16/2/28.
//  Copyright © 2016年 enshu. All rights reserved.
//

#import "WMEFindCollectionHeadView.h"
#import <UIImageView+WebCache.h>

#pragma mark - 发现的头部collectionView
@interface WMEFindCollectionHeadView ()
@property (nonatomic, retain)UIImageView *backImg;//背景图片
@property (nonatomic, retain)UILabel *imgBackLabel;//背景图片
@property (nonatomic, retain)UIImageView *findImg;//发现的图片
@property (nonatomic, retain)UILabel *findName;//发现的名字
@property (nonatomic, retain)UILabel *findContent;//发现的内容
@end

@implementation WMEFindCollectionHeadView
-(void)dealloc
{
    [_backImg release];
    [_imgBackLabel release];
    [_findImg release];
    [_findName release];
    [_findContent release];
    [_dic release];
    [super dealloc];
}

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.backImg = [[UIImageView alloc] init];
        _backImg.contentMode = UIViewContentModeScaleAspectFill;
        _backImg.clipsToBounds = YES;
        //        _backImg.backgroundColor = [UIColor cyanColor];
        [self addSubview:_backImg];
        [_backImg release];
        
        
        self.imgBackLabel = [[UILabel alloc] init];
        _imgBackLabel.backgroundColor = [UIColor whiteColor];
        [self addSubview:_imgBackLabel];
        
        self.findImg = [[UIImageView alloc] init];
        //        _clubImg.backgroundColor = [UIColor yellowColor];
        [self addSubview:_findImg];
        [_findImg release];
        
        self.findName = [[UILabel alloc] init];
        //        _clubName.backgroundColor = [UIColor orangeColor];
        _findName.textColor = [UIColor whiteColor];
        _findName.font = [UIFont boldSystemFontOfSize:15];
        _findName.textAlignment = NSTextAlignmentCenter;
        [self addSubview:_findName];
        [_findName release];
        
        self.findContent = [[UILabel alloc] init];
        //        _clubContent.backgroundColor = [UIColor redColor];
        _findContent.textColor = [UIColor whiteColor];
        _findContent.textAlignment = NSTextAlignmentCenter;
        _findContent.font = [UIFont systemFontOfSize:13];
        _findContent.numberOfLines = 0;
        [self addSubview:_findContent];
        [_findContent release];
    }
    return self;
}

- (void)setDic:(NSDictionary *)dic
{
    if (_dic != dic) {
        [_dic release];
        _dic = [dic retain];
        [_backImg sd_setImageWithURL:[NSURL URLWithString:_dic[@"image"]]];
        
        [_findImg sd_setImageWithURL:[NSURL URLWithString:_dic[@"image"]]];
        
        _findName.text = _dic[@"name"];
        
        _findContent.text = _dic[@"desc"];
    }
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    
    _backImg.frame = CGRectMake(0, 0, WIDTH, 150);
    
    UIVisualEffect *blurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight];
    
    UIVisualEffectView *visualEffectView = [[UIVisualEffectView alloc] initWithEffect:blurEffect];
    
    visualEffectView.frame = _backImg.bounds;
    
    [_backImg addSubview:visualEffectView];
    
    _imgBackLabel.frame = CGRectMake((WIDTH - 64) / 2, 18, 64, 64);
    
    _findImg.frame = CGRectMake((WIDTH - 60) / 2, 20, 60, 60);
    
    _findName.frame = CGRectMake(0, _findImg.frame.origin.y + _findImg.frame.size.height + 10, WIDTH, 20);
    
    _findContent.frame = CGRectMake(0, _findName.frame.size.height + _findName.frame.origin.y + 10, WIDTH, 20);
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
